package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    /**根据分类id查询菜品数量
     *
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategory(Long categordId);


    /**插入菜品数据
     *  @AutoFill(value = OperationType.INSERT)为公共字段自动填充
     * @param dish
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    /**菜品分页查询
     *
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);


    /*
    * 根据主键查询菜品(主键是菜品id)
    * */
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

 /*   *//*
    * 根据主键删除菜品数据*//*
    @Delete("delete from dish where id = #{id}")
    void deleteById(Long id);*/

    //根据菜品ID集合批量删除菜品数据
    void deleteByIds(List<Long> ids);


    //根据ID动态修改菜品
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    List<Dish> list(Long categoryId);

    @Select("select count(id) from dish where status =#{status}")
    Integer getDishCountByStatus(Integer status);

    /* List<DishVO> getDishandFlavos(Long categoryId);*/
}
